package repository

import (
	"log"
	"palms/model"
	"xorm.io/xorm"
)

type RoomRepository interface {
	List(pageNo int, pageSize int) ([]model.Room, error)

	Get(id int64) (*model.Room, error)

	Create(task model.Room) (int64, error)

	Delete(id int64) error

	UpdateTopic(room model.Room) error
}

func NewRoomRepository(engine *xorm.Engine) RoomRepository {
	return &roomRepository{
		engine: engine,
	}
}

type roomRepository struct {
	engine *xorm.Engine
}

func (r *roomRepository) List(pageNo int, pageSize int) ([]model.Room, error) {
	var rooms = make([]model.Room, 0)
	err := r.engine.Limit(pageSize, pageNo*pageSize).Find(rooms)
	if err != nil {
		log.Printf("查询群信息列表失败[error:%s]\n", err.Error())
		return nil, err
	}
	return rooms, nil
}

func (r *roomRepository) Get(id int64) (*model.Room, error) {
	//TODO implement me
	panic("implement me")
}

func (r *roomRepository) Create(task model.Room) (int64, error) {
	//TODO implement me
	panic("implement me")
}

func (r *roomRepository) Delete(id int64) error {
	//TODO implement me
	panic("implement me")
}

func (r *roomRepository) UpdateTopic(room model.Room) error {
	//TODO implement me
	panic("implement me")
}
